#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QMenuBar* menubar = new QMenuBar(this);
    setMenuBar(menubar);

    QMenu* menu1 = new QMenu("1");
    QMenu* menu2 = new QMenu("2");
    QMenu* menu3 = new QMenu("3");

    //添加一个父菜单
    menubar->addMenu(menu1);
    //给父菜单添加二个子菜单
    menu1->addMenu(menu2);
    menu1->addSeparator();
    menu1->addMenu(menu3);

    //给子菜单添加菜单项
    QAction* a = new QAction("11");
    QAction* b = new QAction("22");
    menu3->addAction(a);
    menu3->addAction(b);


}

MainWindow::~MainWindow()
{
    delete ui;
}

